import request from '@/utils/request.js'

// 获取所有学院，专业，班级
export function findCMC() {
  return request({
    url: '/college/college_major_classes'
  })
}

/**
 * 动态查询学院、专业、班级
 * @param {Object} options （pageName查询对象，label查询方式，value数据）
 * @returns 
 */
// 例如：{pageName: classes, label: class_name, value: '软件'}
export function searchCMC(options) {
  const { pageName, label, value } = options
  return request({
    url: `/${pageName}/name`,
    method: 'post',
    data: {
      [label]: value,
      page_num: options.page_num,
      page_size: options.page_size
    }
  })
}

// 创建
export function createCMC(options) {
  const { pageName, formData} = options
  return request({
    url: `/${pageName}/create`,
    method: 'post',
    data: formData
  })
}

// 修改
export function updateCMC(data) {
  return request({
    url: '/classes/update',
    method: 'post',
    data
  })
}

// 删除
export function deleteCMC(id) {
  return request({
    url: `/classes/${id}`,
    method: 'delete'
  })
}